package cn.itsource.ymcc.doc;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * 课程文档实体类：数据字段与数据库中保持一致
 *  不同的地方是：数据库中我们是采用了垂直分表的
 *  课程文档实体类的字段》基本上是课程垂直分表那4张表的所有字段
 *
 *  字段设计：根据业务场景来分析：
 *      1.字段类型：基本上要求与数据库中对应字段类型一致
 *          字符串类型需要特别注意是否需要分词
 *      2.如果要展示或排序：store就设置为true
 *      3.如果要搜索：index就设置为true
 */
@Data
@Document(indexName = "ymcc",type = "course")
public class CourseDoc {
    @Id
    private Long id;

    /**
     * 课程名称
     */
    @Field(type = FieldType.Text,store = true,index = true,analyzer = "ik_max_word")
    private String name;

    /**
     * 适用人群
     */
    @Field(type = FieldType.Keyword,store = true,index = true)
    private String forUser;

    /**
     * 课程分类
     */
    @Field(type = FieldType.Long,store = true,index = true)
    private Long courseTypeId;
    @Field(type = FieldType.Keyword,store = true,index = true)
    private String courseTypeName;

    /**
     * 课程等级
     */
    @Field(type = FieldType.Long,store = true,index = true)
    private Long gradeId;
    @Field(type = FieldType.Keyword,store = true,index = true)
    private String gradeName;

    /**
     * 课程的开课时间
     */
    @Field(type = FieldType.Long,store = true,index = true)
    private Long startTime;
    /**
     * 课程的节课时间
     */
    @Field(type = FieldType.Long,store = true,index = true)
    private Long endTime;
    /**
     * 上线时间
     */
    @Field(type = FieldType.Long,store = true,index = true)
    private Long onlineTime;

    /**
     * 封面，云存储地址
     */
    @Field(type = FieldType.Keyword,store = true,index = false)
    private String pic;

    /**
     * 时长，以分钟为单位
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer totalMinute = 0;

    /**
     * 章节数
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer chapterCount = 0;

    /**
     * 讲师，逗号分隔多个
     */
    @Field(type = FieldType.Keyword,store = true,index = false)
    private String teacherNames;


    /**
     * 详情
     */
    @Field(type = FieldType.Keyword,store = true,index = false)
    private String description;
    /**
     * 简介
     */
    @Field(type = FieldType.Keyword,store = true,index = false)
    private String intro;

    /**
     * 收费规则：，收费1免费，2收费
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer charge;

    /**
     * 咨询qq
     */
    @Field(type = FieldType.Keyword,store = true,index = false)
    private String qq;

    /**
     * 价格
     */
    @Field(type = FieldType.Double,store = true,index = true)
    private Double price;
    /**
     * 原价
     */
    @Field(type = FieldType.Double,store = true,index = true)
    private Double priceOld;

    /**
     * 有效期：天为单位
     */
    @Field(type = FieldType.Integer,store = true,index = false)
    private Integer validDays;

    /**
     * 销量
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer saleCount = 0;

    /**
     * 浏览量
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer viewCount = 0;

    /**
     * 评论数
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer commentCount = 0;

    /**
     * 收藏量
     */
    @Field(type = FieldType.Integer,store = true,index = true)
    private Integer collectCount = 0;

}
